﻿@model Model.AppUserList
@{
    ViewBag.Title = "OffShelves";
    Layout = "~/Views/Shared/_JQBaseLayOut.cshtml";
}
@using Model

@section JQscriptSection{
    <script type="text/javascript">
        $(document).ready(function () {
            var curr_time = new Date();
            var strDate = curr_time.getFullYear() + "-";
            strDate += curr_time.getMonth() + 1 + "-";
            strDate += curr_time.getDate();
            $("#CheckTimeS").datebox("setValue", strDate);
            $("#CheckTimeE").datebox("setValue", strDate);
            InitGrid();
        });

        HandleDom.ClassTriggerClick("icon-add", function () {
            $('#hiddenOFFSHELVESID').val();
            HandleDialog.OpenDialogByAdd('dlg', '添加下架指令', function () {
                HandleData.ClearForm('location');

            });
        });

        HandleDom.ClassTriggerClick("icon-edit", function () {
            var row = HandleData.GetDataGridSelected("dg");
            edit(row);
        });

        function saveData(isClose) {
            HandleRequest.submitForm('location', '@Url.Action("SaveData", "OffShelves")', function (data) {
                eval('data=' + data);
                if (data.success == true) {
                    layer.alert('执行成功!', 9);
                    InitGrid();
                    HandleDialog.CloseDialog('dlg');
                } else {
                    layer.msg(data.msg, 1);
                }

            });
        }


        HandleDom.ClassTriggerClick("icon-remove", function () {
            layer.confirm('是否确定删除？', function (index) {
                var ids = "";
                var rows = $('#dg').datagrid('getSelections');
                var n = 0;
                for (var i = 0; i < rows.length; i++) {
                    ids = ids + rows[i].OFFSHELVESID + ",";
                    if (rows[i].FLAG != "0") {
                        n = 1;
                    }
                }
                if (n != 0) {
                    layer.alert("要删除的指令中有非未处理的指令！", 3);
                } else {
                    $('#hiddenIDlist').val(ids);
                    deleteDate();

                }
            });
          

        });

        HandleDom.ClassTriggerClick("icon-batchRemove", function () {
            HandleData.ClearForm('location');
            HandleDialog.OpenDialogByAdd('p2', '按批次删除指令');
        });



        //编辑
        function edit(row) {
            HandleData.ClearForm('location');
            HandleDialog.OpenDialog(row, 'dlg', '编辑下架指令', function () {
                $('#batchNo').val(row.BATCHNO)
                $('#txtGoodsCode').val(row.GOODSCODE)
                $('#txtQTY').val(row.QTY);
                $('#txtRemark').val(row.REMARK);

                $("#offShelvesDate").datebox("setValue", FormatData.formatDate(row.OFFSHELVESDATE));
                $('#hiddenOFFSHELVESID').val(row.OFFSHELVESID);

            });
        }

        //导入指令下架
        function ImpotExcel() {
            var form = $('#import');
            form.form('submit', {
                url: '@Url.Content("~/OffShelves/ImportOffshelvesInfo")',
                success: function (data) {
                    eval('data=' + data);
                    if (data.success) {
                        $("#txtDBBCBATCHNO").val(data.batch);
                        layer.alert('导入成功!', 9);
                        InitGrid();
                    } else {
                        layer.alert(data.msg, 3);
                    }
                }
            });
        }

        function deleteDate() {
            HandleRequest.submitForm('location', '@Url.Action("Delete", "OffShelves")', function (data) {
                eval('data=' + data);
                if (data.success == true) {
                    layer.alert('执行成功!', 9);
                    InitGrid();
                } else {
                    layer.alert(data.msg, 3);
                }

            });
        }
        function saveDataAll() {
            HandleRequest.submitForm('location_batch', '@Url.Action("DeleteBatch", "OffShelves")', function (data) {
                eval('data=' + data);
                if (data.success == true) {
                    layer.alert('执行成功!', 9);
                    InitGrid();
                    HandleDialog.CloseDialog('p2');
                } else {
                    layer.alert(data.msg, 3);
                }
            });
        }
        function InitGrid() {
            var txtSBatchNO = $('#txtSBatchNO').val();
            var txtSGOODSCODE = $('#txtSGOODSCODE').val();
            var txtSGOODSNAME = $('#txtSGOODSNAME').val();
            var startDate = $('#CheckTimeS').datebox('getValue');
            var endDate = $('#CheckTimeE').datebox('getValue');
            var txtOpcontent = $('#opcontent').val();
            var sFlag = $('#SFlag').combobox('getValue');
            var cellNo = $('#CellNo').combobox('getValue');
            var txtlocationCode = $('#txtSLOCATIONCODE').val();
            var txtImportBatchNo = $('#txtDBBCBATCHNO').val();
            var offshelvesType = $('#OffshelvesType').combobox('getValue');

            queryParams = {
                sBatchNO: txtSBatchNO,
                sGoodsCode: txtSGOODSCODE,
                sFlag: sFlag,
                checkTimeS: startDate,
                checkTimeE: endDate,
                cellNo: cellNo,
                sGoodsName: txtSGOODSNAME,
                locationCode: txtlocationCode,
                importBatchNo: txtImportBatchNo,
                offshelvesType: offshelvesType
            }
            HandleData.InitDataGrid('dg', '/OffShelves/InitJsonResult', 'toolbar', queryParams, 'OFFSHELVESID', false, function (data) { },
                function (rowIndex, rowData) {//双击
                    edit(rowData);
                });
        }
    </script>
}

<body style="background-color: ButtonFace; font-size: 17px">
    <div class="easyui-panel" title="查询条件" style="height: 130px; padding: 5px; background: #fafafa; width: 1700px;">
        <form id="query" method="post">
            <table>
                <tr>
                    <td>作业批次号:
                    </td>
                    <td>
                        <input id="txtSBatchNO" name="txtSBatchNO" style="width: 154px" />
                    </td>
                    <td>商品编码:
                    </td>
                    <td>
                        <input id="txtSGOODSCODE" name="txtSGOODSCODE" style="width: 154px" />
                    </td>
                    <td>商品名称:
                    </td>
                    <td>
                        <input id="txtSGOODSNAME" name="txtSGOODSNAME" style="width: 154px" />
                    </td>
                    <td>货位号:
                    </td>
                    <td>
                        <input id="txtSLOCATIONCODE" name="txtSLOCATIONCODE" style="width: 154px" />
                    </td>
                    <td>指令类型:
                    </td>
                    <td>
                         <input id="OffshelvesType" class="easyui-combobox" name="OffshelvesType" style="width: 85px;" data-options="valueField:'CODE',textField:'NAME',url:'@Url.Action("OffShelvesTypeList", "BaseData", new { IsSetAll = 0})',editable:false">
                        
                    </td>
                </tr>
            </table>
            <table>
                <tr>
                    <td>状态:
                    </td>
                    <td>
                        <select id="SFlag" class="easyui-combobox" name="SFlag" style="width: 154px;">
                            <option value="">全部</option>
                            <option value="0">未处理</option>
                            <option value="40">在执行</option>
                            <option value="100">已完结</option>
                        </select>
                    </td>
                    <td>库位:
                    </td>
                    <td>
                        <select id="CellNo" class="easyui-combogrid" name="CellNo" style="width: 154px;"
                            data-options="
                        idField:'CELLNO',
                        textField:'CELLNO',
                        url:'@Url.Content("/BaseData/CellNoList?IsSetAll=0")',
                        columns:[[
                            {field:'CELLNO',title:'库位',width:120}
                        ]]
                    ">
                        </select>
                    </td>
                    <td>指定配送日期：
                    </td>
                    <td>
                        <input class="easyui-datebox" id="CheckTimeS" name="CheckTimeS" style="width: 140px;" />
                    </td>
                    <td>~：
                    </td>
                    <td>
                        <input class="easyui-datebox" id="CheckTimeE" name="CheckTimeE" style="width: 140px;" validtype="compareDate['#CheckTimeS']" />
                    </td>
                    <td>导入批次号:
                    </td>
                    <td>
                        <input id="txtDBBCBATCHNO" name="txtDBBCBATCHNO" style="width: 154px" validtype="integer['#txtDBBCBATCHNO']" />
                    </td>
                    <td>
                        <a id="btnSerach" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onclick="InitGrid()">查询</a>
                    </td>
                </tr>
            </table>
        </form>
        <form id="import" method="post" enctype="multipart/form-data">
            <table>
                <tr>
                    <td>
                        <input id="FileUpload" type="file" name="files" style="width: 250px; height: 24px; background: White"
                            class="easyui-validatebox" />
                        <a id="btnGet" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-excel'" onclick="ImpotExcel()">导入</a>
                    </td>
                </tr>
            </table>
        </form>
    </div>
    <div style="min-height: 720px; width: 1700px;">
        <table id="dg" title="指令下架信息" style="min-height: 600px;">
            <thead>
                <tr>
                    <th data-options="field:'ck',checkbox:true"></th>
                    <th data-options="field:'BATCHNO',width:30">作业批次号</th>
                    <th data-options="field:'GOODSCODE',width:60">商品编码</th>
                    <th data-options="field:'GOODSNAME',width:80">商品名称</th>
                    <th data-options="field:'CELLNO',width:50">库位</th>
                    <th data-options="field:'LOCATIONCODE',width:30">货位</th>
                    <th data-options="field:'QTY',width:30">数量</th>
                    <th data-options="field:'QTYEXCE',width:30">执行数量</th>
                    <th data-options="field:'FLAG',width:30,sortable:true,formatter:function(value, rowData, rowIndex){ return FormatData.formatflag(value);}">状态</th>
                    <th data-options="field:'OFFSHELVESDATE',width:80,sortable:true,formatter:function(value, rowData, rowIndex){ return FormatData.formatDate(value);}">指定配送日期</th>
                    <th data-options="field:'CREATER',width:30">创建人</th>
                    <th data-options="field:'REPLACEBATCHNO',width:30">替代批次号</th>
                    <th data-options="field:'IMPORTBATCHNO',width:80">人工导入批次号</th>
                    <th data-options="field:'EDITDATE',width:80,sortable:true,formatter:function(value, rowData, rowIndex){ return FormatData.formatDate(value);}">修改时间</th>
                    <th data-options="field:'REMARK',width:80">备注</th>
                </tr>
            </thead>
        </table>
    </div>
    <div id="dlg" class="easyui-dialog" style="width: 620px; height: 200px; top: 300px; left: 400px; padding: 2px"
        data-options="closed:true,buttons:'#dlg-buttons',modal:true">
        <form id="location" method="post">
            <table>
                <tr>
                    <td>批次号:
                    </td>
                    <td>
                        <input id="hiddenIDlist" name="hiddenIDlist" type="hidden" />
                        <input id="hiddenOFFSHELVESID" name="hiddenOFFSHELVESID" type="hidden" />
                        <input id="batchNo" name="BatchNo" maxlength="32" style="width: 154px" />
                    </td>
                    <td>商品编码:
                    </td>
                    <td colspan="2">
                        <input id="txtGoodsCode" name="txtGoodsCode" maxlength="10" style="width: 154px" onblur="checkgoodscode()" />
                    </td>
                </tr>
                <tr>
                    <td>数量:
                    </td>
                    <td>
                        <input id="txtQTY" name="txtQTY" maxlength="10" style="width: 154px" />
                    </td>
                    <td>指定配送日期:
                    </td>
                    <td colspan="2">
                        <input class="easyui-datebox" id="offShelvesDate" name="offShelvesDate" style="width: 154px;" />
                    </td>
                </tr>
                <tr>
                    <td>备注:
                    </td>
                    <td colspan="4">
                        <input id="txtRemark" name="txtRemark" maxlength="255" style="width: 520px" />
                    </td>
                </tr>

                <tr>
                    <td colspan="5">
                        <a id="btnSave" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-save'" onclick="saveData(true)">保存</a>
                    </td>
                </tr>
            </table>
        </form>
    </div>
    <div id="p2" class="easyui-dialog" style="width: 420px; height: 150px; top: 300px; left: 400px; padding: 2px"
        data-options="closed:true,buttons:'#dlg-buttons',modal:true">
        <form id="location_batch" method="post">
            <table>
                <tr>
                    <td>导入批次号:
                    </td>
                    <td colspan="2">
                        <input id="txtOffShelvesBatch" name="txtOffShelvesBatch" style="width: 154px" />
                    </td>
                    <td></td>
                    <td>
                        <a id="btnSave_batch" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-save'" onclick="saveDataAll()">确定</a>
                    </td>
                </tr>
            </table>
        </form>
    </div>
    @Html.Partial("~/Views/Shared/_PartialToolbar.cshtml", new Toolbar
{
    GridName = "dg",
    GridType = "datagrid",
    ToolbarName = "toolbar",
    FunctionModule = new Dictionary<string, List<FunctionModule>>()
    {
        {"Function",new List<FunctionModule>()
            {
              new FunctionModule(){Name = "Add",IsEnable =true },
              new FunctionModule(){Name = "Edit",IsEnable =true },
              new FunctionModule(){Name = "Remove",IsEnable =true },
              new FunctionModule(){Name = "Reload",IsEnable =true },
              new FunctionModule(){Name = "Collapse",IsEnable =false },
              new FunctionModule(){Name = "Exporter",IsEnable =false },
              new FunctionModule(){Name = "BatchRemove",IsEnable =true },
              
            }
        }
    }
})

</body>



